package com.fxwater.biz.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fxwater.biz.domain.FxwDataInfo;
import com.fxwater.biz.domain.PumpStationInfo;
import com.fxwater.biz.mapper.PumpStationServiceMapper;
import com.fxwater.biz.service.IPumpStationService;
import com.fxwater.common.core.text.Convert;

@Service
public class PumpStationServiceImpl implements IPumpStationService {
	
	@Autowired
	private PumpStationServiceMapper pumpStationServiceMapper;

	@Override
	public List<PumpStationInfo> selectPumpStationInfoList(PumpStationInfo pumpStationInfo) {
		return pumpStationServiceMapper.selectPumpStationInfoList(pumpStationInfo);
	}

	@Override
	public int removePumpStationInfo(String ids) {
		// TODO Auto-generated method stub
		int row = pumpStationServiceMapper.removePumpStationInfo(Convert.toStrArray(ids));
//		if( row > 0 ) {
//			//删除用户和泵站的绑定关系
//			pumpStationServiceMapper.removePumpUserRelation(Convert.toStrArray(ids));
//		}
		return row;
	}

	@Override
	public int addPumpSatation(PumpStationInfo pumpStationInfo) {
		
//		String latLngs = pumpStationInfo.getBoundary();
//		if(!StringUtils.isEmpty(latLngs)) {
//			String [] lngLat = latLngs.split(";");
//			JSONArray ja = new JSONArray();
//			if(lngLat != null && lngLat.length > 0 ) {
//				for(String str : lngLat ) {
//					String [] temp = str.split(",");
//					JSONObject ad = new JSONObject();
//					ad.put("lng", temp[0]);
//					ad.put("lat", temp[1]);
//					ja.add(ad);
//				}
//			}
//			pumpStationInfo.setBoundary(ja.toString());
//		}
		int row = pumpStationServiceMapper.addPumpSatation(pumpStationInfo);
//		 if(row > 0) {
//			 //绑定泵站和用户关系
//			 return pumpStationServiceMapper.saveUserPumpStationRelation(pumpStationInfo.getId(),ShiroUtils.getUserId());
//		 }
		return row;
	}

	@Override
	public int editSavePumpStationInfo(PumpStationInfo pumpStationInfo) {
//		pumpStationInfo.setUpdateBy(ShiroUtils.getLoginName());
		return pumpStationServiceMapper.editSavePumpStationInfo(pumpStationInfo);
	}

	@Override
	public List<PumpStationInfo> selectStationNoUseByName(PumpStationInfo pumpStationInfo) {
		// TODO Auto-generated method stub
		return pumpStationServiceMapper.selectStationNoUseByName(pumpStationInfo);
	}

	@Override
	public List<FxwDataInfo> selectPumpStationInfoDataList(FxwDataInfo fxwDataInfo) {
		return pumpStationServiceMapper.selectPumpStationInfoDataList(fxwDataInfo);
	}

}
